package com.metadata_system.common.db.mapper;

import com.metadata_system.common.db.entity.ProjectUser;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface ProjectUserMapper extends Mapper<ProjectUser> {
    @Select("select user_id from md_project_user where project_id = #{projectId} and role='Owner'")
    Integer getBelongUserId(Integer projectId);

    @Select("select role from md_project_user where project_id = #{projectId} and user_id = #{userId}")
    List<String> getRoles(Integer projectId, Integer userId);

    @Select("select COUNT(*) from md_project_user where project_id = #{projectId} and user_id = #{userId}")
    Integer isProjectUser(Integer projectId, Integer userId);
}